from itertools import permutations, product, combinations
from rich.console import Console
from rich.table import Table

l = [True, False]

console = Console()

name_dict = {
    1: '全真',
    2: '有真即真(或)',
    3: '同真异左',
    4: '取左',
    5: '同真异右',
    6: '取右',
    7: '同真异假(异或)',
    8: '有假即假(且)',
    9: '有假即真',
    10: '同假异真',
    11: '反右',
    12: '同假异左',
    13: '反左',
    14: '同假异右',
    15: '有真即假',
    16: '全假',
}

# 全真
# 全假
# 取左
# 取右
# 反左
# 反右

# 有真即真(或)
# 有真即假(且)
# 有假即假
# 有假即真

# 同真异假(异或)
# 同真异左
# 同真异右
# 同假异真
# 同假异左
# 同假异右

# 如果 那么 
# T   T      T
# T   F      F
# F   T      ?
# F   F      ?

truth_table = list(product(l, repeat=2))
count = 0
for answer in product(l, repeat=4):
    count += 1
    console.print(str(count), '. ', name_dict[count])
    table = Table(show_header=True)
    table.add_column('left')
    table.add_column('right')
    table.add_column('result')
    # console.print('|左侧|右侧|返回值')
    # console.print('|----|----|----|')
    for i in range(len(answer)):
        table.add_row(str(truth_table[i][0]), str(truth_table[i][1]), str(answer[i]))
        # console.print(f'|{str(truth_table[i][0])}|{str(truth_table[i][1])}|{str(answer[i])}|')
    console.print(table)